package com.example.service;

import com.example.entity.Transfer;
import com.example.mapper.TransferMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TransferService {

    @Resource
    TransferMapper transferMapper;

    public void add(Transfer transfer) {
        transferMapper.insert(transfer);
    }

    public void deleteById(Integer id) {
        transferMapper.deleteById(id);
    }

    public void updateById(Transfer transfer) {
        transferMapper.updateById(transfer);
    }

    public List<Transfer> selectAll() {
        return transferMapper.selectAll();
    }

    public Transfer selectById(Integer id) {
        return transferMapper.selectById(id);
    }

    public PageInfo<Transfer> selectPage(Integer pageNum, Integer pageSize) {
        //开启分页查询
        PageHelper.startPage(pageNum, pageSize);
        List<Transfer> list = transferMapper.selectAll();
        return PageInfo.of(list);
    }
}
